package cn.mumzone.pos.ui.adapter.warehouse;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import cn.mumzone.basic.adapter.rv.ItemViewDelegate;
import cn.mumzone.basic.adapter.rv.ViewHolder;
import cn.mumzone.pos.AppConstants;
import cn.mumzone.pos.R;
import cn.mumzone.pos.model.WarehouseDetailEntity;

/**
 * Created By Dlx
 * on 2019/10/10
 */
public class ItemView_ShortWarehouseDetail implements ItemViewDelegate<WarehouseDetailEntity.GoodsListBean> {
    private String inType;

    //    public ItemView_ShortWarehouseDetail(String inType) {
//        this.inType = inType;
//    }
    public void setInType(String inType) {
        this.inType = inType;
    }

    @Override
    public int getItemViewLayoutId() {
        return R.layout.item_warehouse_short;
    }

    @Override
    public boolean isForViewType(WarehouseDetailEntity.GoodsListBean item, int position) {
        //todo 无批次时返回true
        return 0 == item.getIsBatch();
    }

    @Override
    public void convert(ViewHolder holder, WarehouseDetailEntity.GoodsListBean entity, int position) {
        if (AppConstants.WAREHOUSE_OTHER.equals(inType)) {
            holder.setVisible(R.id.ll_price, true);
            holder.setText(R.id.tv_good_price, "￥" + entity.getGoodsBatchNumList().get(0).getGoodsPrice());
        }

        holder.setText(R.id.tv_good_name, entity.getGoodsName());
        holder.setText(R.id.tv_good_unit, entity.getGoodsSpec());
        holder.setText(R.id.tv_good_num, entity.getGoodsBatchNumList().get(0).getGoodsNum() + entity.getGoodsBatchNumList().get(0).getGoodsUnit());
    }
}
